﻿using System;
using System.Collections.Generic;
using CompactMapper.Orm.Annotations;
using CompactMapper.Orm.Contracts;
using CompactMapper.Orm.UnitOfWork.Mappings;

namespace CompactMapper.Orm.Tests
{
    [Table]
    public class Artist : IKeyedPersistent
    {
        private readonly List<Track> _tracks;
        private readonly List<Record> _records;
              

        [GuidPrimaryKey]
        public IKey Key { get; set; }

        [BooleanColumn]
        public Boolean Persisted { get; set; }

        [TextColumn]
        public String ArtistName { get; set; }

        [HasMany]
        public IEnumerable<Track> Tracks { get { return _tracks; } }


        [HasMany]
        public IEnumerable<Record> Records { get { return _records; } }


        public Artist()
        {
            Key = AbstractKeyFactory.For<Guid>().New();
            _tracks = new List<Track>();
            _records = new List<Record>();
        }


        public void AddTrack(Track track)
        {
            _tracks.Add(track);
        }
        public void AddRecord(Record record)
        {
            _records.Add(record);
        }
    }
}
